package com.management.springboot.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author scy
 * @Description
 * @date 2021/6/11-20:30
 */
@Controller
public class UploadController {
    @RequestMapping(value="/upload")
    public String upload(@RequestParam(value = "email") String email,
                         @RequestParam(value = "username") String username,
                         MultipartFile headerImg,
                         MultipartFile[] lifeImg){
        //如何将文件保存
        if(!(headerImg.isEmpty())){
            try {
                headerImg.transferTo(new File("C:\\Users\\asus\\Desktop\\"+headerImg.getOriginalFilename()));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return null;

    }
}
